package me.zfz.business.controller.impl;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import me.zfz.business.constant.IActionConstant;
import me.zfz.business.controller.base.BaseController;
import me.zfz.base.helper.HttpRequestHelper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.mixsmart.utils.Captcha;

/**
 * 验证码
 * @author author
 *
 */
@Controller
@RequestMapping("captcha")
public class CaptchaController extends BaseController {

	@RequestMapping(method=RequestMethod.GET)
	public void index(HttpServletRequest request, HttpServletResponse response) throws Exception {
		log.info("正在生成验证码-----");
		Captcha cap = new Captcha(100,28,20);
		String code = cap.getString();
		log.info("正在生成验证码--[完成]--["+code+"]-");
		HttpRequestHelper.setSession(request, IActionConstant.SESSION_CAPTCHA_LOGIN, code);
		ImageIO.write(cap.getBuffImage(), "JPEG", response.getOutputStream());
		cap = null;
	}

}
